package ua.kpi.oblamskyiv.factory;

import ua.kpi.oblamskyiv.testcase.Answers;
import ua.kpi.oblamskyiv.testcase.question.*;

public class QuestionFactory {
    public static Question createQuestion(String type,
                                          String value,
                                          Answers correctAnswers,
                                          Answers alternatives,
                                          Double maxDeviation) {
        if (type.equals("single")) {
            return new SingleAnswerQuestion(value, correctAnswers, alternatives);
        } else if (type.equals("yesno")) {
            return new YesNoQuestion(value, correctAnswers);
        } else if (type.equals("multiple")) {
            return new MultipleAnswersQuestion(value, correctAnswers, alternatives);
        } else if (type.equals("enterable")) {
            return new EnterableAnswersQuestion(value, correctAnswers);
        } else if (type.equals("range")) {
            return new RangeAnswerQuestion(value, correctAnswers, maxDeviation);
        } else {
            throw new IllegalArgumentException("Unknown question type!");
        }
    }
}
